#region using

using Castle.MicroKernel.Registration;
using Castle.Windsor;
using CommonServiceLocator.WindsorAdapter;
using HibernatingRhinos.Profiler.Appender.NHibernate;
using Microsoft.Practices.ServiceLocation;
using MvcMall.Core.Contacts.Repositories;
using MvcMall.Data.Repositories;
using NUnit.Framework;
using SharpArch.Core.PersistenceSupport;
using SharpArch.Core.PersistenceSupport.NHibernate;
using SharpArch.Data.NHibernate;
using SharpArch.Testing.NHibernate;

#endregion

namespace MvcMall.Tests.MvcMallData
{
    public class ESDatabaseRepositoryTestsBase
    {
        private readonly bool _commit;

        public ESDatabaseRepositoryTestsBase()
            : this(false)
        {
        }

        public ESDatabaseRepositoryTestsBase(bool commit)
        {
            _commit = commit;
        }

        [SetUp]
        public virtual void SetUp()
        {
            NHibernateProfiler.Initialize();

            RepositoryTestsHelper.InitializeNHibernateSession();
            NHibernateSession.Current.BeginTransaction();
        }

        [TearDown]
        public virtual void TearDown()
        {
            if (_commit)
                NHibernateSession.Current.Transaction.Commit();
            else
                NHibernateSession.Current.Transaction.Rollback();
            RepositoryTestsHelper.Shutdown();
        }
    }



}